package org.dstart.object.menulist.sub
{
	import flash.display.Sprite;

	public class FlagIcons extends Sprite
	{
		private var lineColor:uint;			/** 线条颜色 **/
		private var fillColor:uint;			/** 填充颜色 **/
		private var flagModel:Boolean;		/** 状态标识 **/
		
		public function FlagIcons(lc:uint = 0x000000, fc:uint = 0xFFFFFF)
		{
			lineColor = lc;
			fillColor = fc;
			
			this.model = true;
		}
		
		public function set model(flag:Boolean):void
		{
			flagModel = flag;
			
			this.graphics.clear();

			DrawBackground();
			
			if(flag)
			{
				DrawCloseImage();
			}
			else
			{
				DrawOpenImage();
			}				
		}
		
		public function get model():Boolean
		{
			return this.flagModel;
		}
		
		public function set color(col:uint):void
		{
			lineColor = col;
			
			DrawBackground();
			
			if(flagModel)
			{
				DrawCloseImage();
			}
			else
			{
				DrawOpenImage();
			}				
		}
		
		/*******************************************/
		
		private function DrawOpenImage():void
		{
			this.graphics.lineStyle(1, lineColor, 1);
			this.graphics.moveTo(0, 5);
			this.graphics.lineTo(10, 5);			
		}
		
		private function DrawCloseImage():void
		{
			this.graphics.lineStyle(1, lineColor, 1);
			this.graphics.moveTo(0, 5);
			this.graphics.lineTo(10, 5);
			this.graphics.moveTo(5, 0);
			this.graphics.lineTo(5, 10);		
		}
		
		private function DrawBackground():void
		{
			this.graphics.lineStyle(1, lineColor, 1);
			this.graphics.beginFill(fillColor, 0);
			this.graphics.drawRect(0, 0, 10, 10);
			this.graphics.endFill();	
		}
	}
}